#pragma once

#include "DLL.h"
#include <MyViews/Tool.h>

class ZoomView;
typedef ZoomView ZoomBench;

namespace My {

class MaskEditor;

///Wire Tool is base class for any sizeable tool having both cross Windows cursor 
///and aditional manual drawn cursor (wire)
class DLL_API WireTool : public Tool 
{
public:
	WireTool(ZoomBench & owner);

	ZoomBench & GetBench()
		{ return m_Owner; }
	ZoomBench const & GetBench() const
		{ return m_Owner; }

	virtual void IncreaseSize(int inc) = 0;
	virtual CRect GetWireRect(CPoint p) = 0;
	virtual void DrawWire(CDC * pDC, CPoint p, int width) = 0;
	virtual void Synchronize() = 0;

	void ShowWire(CDC * pDC); 
	void ShowWire(); 
	void HideWire(CDC * pDC); 
	void HideWire(); 
	void RedrawWire();
	bool IsWireVisible() const
		{ return m_WireVisible; }

public:
	enum MouseState {
		ButtonsUp = 0,
		LButtonDown = 1,
		RButtonDown = 2
	};
	//WireTool translates mouse clicks and moves into Select() calls; MouseState != 0
	virtual void Select(CPoint p, int MouseState) = 0;

public:
	virtual void Activate(); 
	virtual void Deactivate(); 
	virtual void Show(); 
	virtual void Hide(); 

	virtual void PaintRect(CDC * pDC, const CRect & r);
	virtual void OnLButtonDown(UINT nFlags, CPoint p);
	virtual void OnLButtonDblClk(UINT nFlags, CPoint p);
	virtual void OnLButtonUp(UINT nFlags, CPoint p);
	virtual void OnRButtonDown(UINT nFlags, CPoint p);
	virtual void OnRButtonDblClk(UINT nFlags, CPoint p);
	virtual void OnRButtonUp(UINT nFlags, CPoint p);
	virtual void OnMouseMove(UINT nFlags, CPoint p);
	virtual void OnMouseEnter(UINT nFlags, CPoint p);
	virtual void OnMouseLeave();

	virtual void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	virtual void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);

	virtual bool OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);

protected:
	//{{AFX_MSG(WireTool)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

protected:
	ZoomBench & m_Owner;
			  
private:
	const CPoint GetPosition();
	void Apply(CPoint p);

private:
	HCURSOR		m_CursorCross;

	bool	m_Control;
	int		m_MouseState;
	CPoint	m_DrawnWirePosition; //meaningful if m_WireVisible 
	int		m_WireWidth;
	bool	m_WireVisible;
	bool	m_ShowWire;
	bool	m_Hidden;
	int		m_SizingRate;
};

} //namespace My
